package com.zztl.infiniteBand.adapter

import android.text.TextUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zztl.infiniteBand.R
import com.zztl.infiniteBand.model.RanklistBean
import com.zztl.infiniteBand.util.DataFormatUtil

/**
 * @desc
 * @auth ${user}
 * @time 2018/5/18  10:12
 */
class RanklistAdapter(layoutResId: Int, data: List<RanklistBean.DataBean>?) : BaseQuickAdapter<RanklistBean.DataBean, BaseViewHolder>(layoutResId, data) {

    override fun convert(helper: BaseViewHolder, item: RanklistBean.DataBean) {
        helper.setText(R.id.tv_user_name, if (TextUtils.isEmpty(item.name)) "——" else item.name)
        helper.setText(R.id.tv_coin_money, DataFormatUtil.converTxtPoint4(item.coin))
        if (item.rank <= 3 && item.rank > 0) {
            helper.setGone(R.id.tv_rangking, false)
            helper.setGone(R.id.iv_ranking, true)
            if (item.rank == 1) {
                helper.setImageResource(R.id.iv_ranking, R.mipmap.jin)
            } else if (item.rank == 2) {
                helper.setImageResource(R.id.iv_ranking, R.mipmap.yin)
            } else {
                helper.setImageResource(R.id.iv_ranking, R.mipmap.tong)
            }
        } else {
            helper.setGone(R.id.tv_rangking, true)
            helper.setGone(R.id.iv_ranking, false)
            helper.setText(R.id.tv_rangking, item.rank.toString())
        }
    }
}
